
/*
 * DSN Test values
 */
YAHOO.dasBrowser.util.testAllDsnEnsembl = function(allDsnEnsembl, divId){
        var myColumnDefs = [
            {key:"sourceId", sortable:true, resizeable:true},
            {key:"description", sortable:true, resizeable:true},
            {key:"sourceUrl", sortable:true, resizeable:true},
            {key:"referenceUrl", sortable:true, resizeable:true},
            {key:"sourceSpecie", sortable:true, resizeable:true},
            {key:"sourceRelease", sortable:true, resizeable:true},
            {key:"sourceType", sortable:true, resizeable:true}
        ];

        this.myDataSource = new YAHOO.util.DataSource(allDsnEnsembl);
        this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
        this.myDataSource.responseSchema = {
            fields: ["sourceId","description","sourceUrl","referenceUrl","sourceSpecie","sourceRelease","sourceType"]
        };

        this.myDataTable = new YAHOO.widget.DataTable(divId, myColumnDefs, this.myDataSource, {caption:"DSN Ensembl object"});
}

/*
 * Sort hash (associative arrays)
 */
YAHOO.dasBrowser.util.assocSort = function(oAssoc) {
	var idx; var key; var arVal = []; var arValKey = []; var oRes = {};
	for (key in oAssoc) {
		arVal[arVal.length] = oAssoc[key];
		arValKey[oAssoc[key]] = key;
	}
	arVal.sort();
	for (idx in arVal)
		oRes[arValKey[arVal[idx]]] = arVal[idx];
	return oRes;
}

/*
 * Find the key for the biggest value on a hash (associative arrays)
 */
YAHOO.dasBrowser.util.findKeyForBiggestValueOnAssocArray = function(oAssoc) {
	var match = null;
	var biggestValue = 0;
	var biggestValueTemp = 0;
	for (key in oAssoc) {
		biggestValueTemp = biggestValue;
		if (oAssoc[key] > biggestValueTemp) {
			biggestValue = oAssoc[key];
			match = key;
		}
	}
	return match;
}

/*
 * display object properties and values
 */
YAHOO.dasBrowser.util.displayObjProp = function(obj){
    var div=document.createElement('div');
    for (var i in obj) {
		//console.log('Name :'+i+' Value :'+obj[i], "container")
	}
}

/*
 * Print text on a specific DIV
 */
YAHOO.dasBrowser.util.printOnTest = function(text){
	var test = YAHOO.util.Dom.get('test');
	var testC = test.innerHTML;
	test.innerHTML = testC + text +"<br>";
    //console.log(text);
}


/*
 * Add Pixel suffix for HTML size values
 */
YAHOO.dasBrowser.util.addPxSuffix = function(value){
	var value = value.toString();
	var newValue = value;
	if(value.indexOf("px") == -1){
		newValue = value + "px";
	};
	return newValue
}
/*
 * Add Pixel suffix for HTML size values
 */
YAHOO.dasBrowser.util.deletePxSuffix = function(value){
	var newValue = value;
	var value = value.toString();
	if(value.indexOf("px") != -1){
		var newValue_temp = value.split("px");
		newValue = newValue_temp[0];
	};
	var newValueTemp = newValue +"";
	if(newValueTemp == "NaN" || newValueTemp == "auto"){
		newValue = 0;
	}
	return parseFloat(newValue);
}

/*
 * Check Even and Odd numbers
 */
YAHOO.dasBrowser.util.isItanOddNumber = function(number){
	var oddNumber = false;
	if (number%2){
		oddNumber = true;
    }
    return oddNumber;
}

/*
 * Find out the color of the chomosome panel
 */
YAHOO.dasBrowser.util.getDivBackgroundColor = function(divId){
	var divContainer = new YAHOO.util.Element(divId);
	var divContainerBgColor = divContainer.getStyle('background-color');
	var divContainerBgColorTemp = divContainerBgColor.toString();
	divContainerBgColorTemp = divContainerBgColorTemp.toLowerCase()
	if (divContainerBgColorTemp.indexOf("rgb") == -1) {
		divContainerBgColor = "#FFFFFF";
	}
	return divContainerBgColor;
}